/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.etrs.formathlon.vue.jsf.form.gest;

import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;
import net.etrs.formathlon.entity.formation.Session;
import net.etrs.formathlon.persistance.formation.SessionFacade;
import net.etrs.formathlon.vue.jsf.utils.CUDBean;

/**
 * ManageBean JSF pour les pages traitant de l'administration des inscriptions.
 * @author OPIF
 */
@ManagedBean
@ViewScoped
public class GestInscriptionBean extends CUDBean<Session, SessionFacade> {

    @EJB
    private SessionFacade facade;
    private SelectItem[] etatOptions;

    @PostConstruct
    @Override
    protected void init() {
        super.init();
        setEtatOptions(createFilterOptions(Session.EtatSession.stringValues()));
    }

    //FROM PRIMEFACES SHOWCASE
    private SelectItem[] createFilterOptions(String[] data) {
        SelectItem[] options = new SelectItem[data.length + 1];

        options[0] = new SelectItem("", "Select");
        for (int i = 0; i < data.length; i++) {
            options[i + 1] = new SelectItem(data[i], data[i]);
        }
        return options;
    }

    /**
     * @return the session
     */
    public Session getSession() {
        return getEntite();
    }

    /**
     * @param session the session to set
     */
    public void setSession(Session session) {
        setEntite(session);
    }

    /**
     * @return the listSession
     */
    public List<Session> getListSession() {
        return getListEntite();
    }

    /**
     * @param listSession the listSession to set
     */
    public void setListSession(List<Session> listSession) {
        setListEntite(listSession);
    }

    @Override
    protected SessionFacade getFacade() {
        return facade;
    }

    /**
     * @return the etatOptions
     */
    public SelectItem[] getEtatOptions() {
        return etatOptions;
    }

    /**
     * @param etatOptions the etatOptions to set
     */
    public void setEtatOptions(SelectItem[] etatOptions) {
        this.etatOptions = etatOptions;
    }
}
